﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using HRM.Entity;
using HRM.BIZ;
using HRM.Utility;
using System.IO;

namespace WebUI.Pages
{
    public partial class ViewEmployee : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                LoadEmployeeDetail();
            }
        }

        protected void LoadEmployeeDetail()
        {
            int id = Request.QueryString["id"].ToInt32();
            Employee emp = new EmployeeBiz().GetByID(id);
            if (emp != null)
            {
                ucEmpNav.EmployeeName = emp.Name;
                ucEmpNav.EmployeeID = emp.EmpID;
                ucEmpNav.RecordID = emp.ID;

                ucEmployeeDetail.CurrentEmployeeDetails = emp;
                if(File.Exists(emp.PictureLink))
                {
                    string filename = Path.GetFileName(emp.PictureLink);
                    imgEmpPicture.ImageUrl = "ImageHandler.aspx?filename=" + filename; 
                }
                else
                {
                    imgEmpPicture.ImageUrl = "ImageHandler.aspx?filename=anonymous.png";
                }
                
            }
        }
    }
}
